{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Otto商品分类——PCA\n",
    "训练集\n",
    "\n",
    "Otto数据集是著名电商Otto提供的一个多类商品分类问题，类别数=9. 每个样本有93维数值型特征（整数，可能表示某种事件发生的次数，已经进行过脱敏处理）。 \n",
    "竞赛官网：https://www.kaggle.com/c/otto-group-product-classification-challenge/data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入必要的工具包\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from sklearn.decomposition import PCA"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>feat_1</th>\n",
       "      <th>feat_2</th>\n",
       "      <th>feat_3</th>\n",
       "      <th>feat_4</th>\n",
       "      <th>feat_5</th>\n",
       "      <th>feat_6</th>\n",
       "      <th>feat_7</th>\n",
       "      <th>feat_8</th>\n",
       "      <th>feat_9</th>\n",
       "      <th>...</th>\n",
       "      <th>feat_85</th>\n",
       "      <th>feat_86</th>\n",
       "      <th>feat_87</th>\n",
       "      <th>feat_88</th>\n",
       "      <th>feat_89</th>\n",
       "      <th>feat_90</th>\n",
       "      <th>feat_91</th>\n",
       "      <th>feat_92</th>\n",
       "      <th>feat_93</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 95 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  feat_1  feat_2  feat_3  feat_4  feat_5  feat_6  feat_7  feat_8  feat_9  \\\n",
       "0   1       1       0       0       0       0       0       0       0       0   \n",
       "1   2       0       0       0       0       0       0       0       1       0   \n",
       "2   3       0       0       0       0       0       0       0       1       0   \n",
       "3   4       1       0       0       1       6       1       5       0       0   \n",
       "4   5       0       0       0       0       0       0       0       0       0   \n",
       "\n",
       "   ...  feat_85  feat_86  feat_87  feat_88  feat_89  feat_90  feat_91  \\\n",
       "0  ...        1        0        0        0        0        0        0   \n",
       "1  ...        0        0        0        0        0        0        0   \n",
       "2  ...        0        0        0        0        0        0        0   \n",
       "3  ...        0        1        2        0        0        0        0   \n",
       "4  ...        1        0        0        0        0        1        0   \n",
       "\n",
       "   feat_92  feat_93   target  \n",
       "0        0        0  Class_1  \n",
       "1        0        0  Class_1  \n",
       "2        0        0  Class_1  \n",
       "3        0        0  Class_1  \n",
       "4        0        0  Class_1  \n",
       "\n",
       "[5 rows x 95 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#读取训练数据\n",
    "dpath = './data/'\n",
    "train = pd.read_csv(dpath +\"Otto_train.csv\")\n",
    "train.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 准备数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_train = train['target']   \n",
    "X_train = train.drop([\"id\", \"target\"], axis=1)\n",
    "\n",
    "#用于存储pca变换后的特征\n",
    "train_id = train['id']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## PCA降维"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "pca = PCA(n_components = 0.85)\n",
    "pca.fit(X_train)\n",
    "    \n",
    "# 在训练集和测试集降维 \n",
    "X_train_pca = pca.transform(X_train)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 绘制PCA维的方差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD8CAYAAACfF6SlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEkVJREFUeJzt3X+MXed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XAw8A3w+8mSk916ep+Q1M6bnuZiI4r6qeSfIi4P8BPwm8BfhAVR1I8t+Bj1TV70yy1lNOU/OPA39aVXf1Oc56vfPvMyWFVqCq/g+DJ7qGDU/vcQeD//BTY5Gap1pVfbqqHuyW/wl4lMG346f2XJ+m5qlVA890qy/qfgr4HgZT1cD0nefFal6W9Rr+Z+u0EgX8RZIHum89ny2+qqo+DYMAAL5ywvX0tSfJw92w0NQMn4zqZsn9JuB+zpJzPVIzTPG5TrIhyUPAk8CHgE8An+umqoEpzI/Rmqvq1Hl+Z3eeb0ly7umOsV7DPwu0nQ3jW99eVd/MYAbVn+iGK3Rm/A7wtcCVwKeBX59sOQtL8mXA+4Gfqqp/nHQ9fSxQ81Sf66r6QlVdyWAGgm3ANyzUbW2rOr3RmpO8Angr8PXAq4CXAqcdDlyv4d9rWolpU1XHun+fBD7I2TMD6me68d5T475PTrieJVXVZ7r/QM8Dv8cUnutuPPf9wB9W1Qe65qk+1wvVfDaca4Cq+hzwv4BvAy7IYKoamOL8GKp5ezfsVlX1eeAPWOI8r9fw7zMlxVRJcl73IRlJzgOuBj52+r2mxvD0HtcDfzLBWno5FaCdH2DKznX3od5twKNV9RtDm6b2XC9W8zSf6ySbklzQLX8p8L0MPqv4SwZT1cD0neeFav6boZuCMPiM4rTneV0+7QPQPU72m3xxSopJfcu4lyRfw+BuHwbfvH7vNNac5I+A72Ywi+BngLcBfwzcCVwGfBLYWVVT8wHrIjV/N4NhiAKOAj92aix9GiT5DuD/Ah8Fnu+af4HBGPpUnuvT1HwdU3quk7ySwQe6GxjcDN9ZVfu6/48HGAyffBj4L90d9cSdpuZ7gU0Mhr0fAn586IPhFx5nvYa/JGlx63XYR5J0Goa/JDXI8JekBhn+ktQgw1+SGmT4S1KDDH9JapDhL0kN+jfZjuqp1wAnYAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "plt.bar(range(len(pca.explained_variance_ratio_)), pca.explained_variance_ratio_)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. 观察Otto商品的特征进行PCA各维的方差，可以得到什么结论？（20分） \n",
    "答：\n",
    "可解释的方差占总方差的85% pca为线性降维，速度很快 最后保留33个主成分 横轴为特征维度的索引 纵轴是每一维的方差。\n",
    "由图可得，前4维特征的方差占比最高，后60个主成分的方差只占15%。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>feat_1_tfidf</th>\n",
       "      <th>feat_2_tfidf</th>\n",
       "      <th>feat_3_tfidf</th>\n",
       "      <th>feat_4_tfidf</th>\n",
       "      <th>feat_5_tfidf</th>\n",
       "      <th>feat_6_tfidf</th>\n",
       "      <th>feat_7_tfidf</th>\n",
       "      <th>feat_8_tfidf</th>\n",
       "      <th>feat_9_tfidf</th>\n",
       "      <th>...</th>\n",
       "      <th>feat_85_tfidf</th>\n",
       "      <th>feat_86_tfidf</th>\n",
       "      <th>feat_87_tfidf</th>\n",
       "      <th>feat_88_tfidf</th>\n",
       "      <th>feat_89_tfidf</th>\n",
       "      <th>feat_90_tfidf</th>\n",
       "      <th>feat_91_tfidf</th>\n",
       "      <th>feat_92_tfidf</th>\n",
       "      <th>feat_93_tfidf</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0.081393</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.075886</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.231403</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.199730</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>0.011987</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.011668</td>\n",
       "      <td>0.105971</td>\n",
       "      <td>0.021681</td>\n",
       "      <td>0.080435</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.008244</td>\n",
       "      <td>0.022456</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.124622</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.145988</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 95 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  feat_1_tfidf  feat_2_tfidf  feat_3_tfidf  feat_4_tfidf  feat_5_tfidf  \\\n",
       "0   1      0.081393           0.0           0.0      0.000000      0.000000   \n",
       "1   2      0.000000           0.0           0.0      0.000000      0.000000   \n",
       "2   3      0.000000           0.0           0.0      0.000000      0.000000   \n",
       "3   4      0.011987           0.0           0.0      0.011668      0.105971   \n",
       "4   5      0.000000           0.0           0.0      0.000000      0.000000   \n",
       "\n",
       "   feat_6_tfidf  feat_7_tfidf  feat_8_tfidf  feat_9_tfidf  ...  feat_85_tfidf  \\\n",
       "0      0.000000      0.000000      0.000000           0.0  ...       0.075886   \n",
       "1      0.000000      0.000000      0.231403           0.0  ...       0.000000   \n",
       "2      0.000000      0.000000      0.199730           0.0  ...       0.000000   \n",
       "3      0.021681      0.080435      0.000000           0.0  ...       0.000000   \n",
       "4      0.000000      0.000000      0.000000           0.0  ...       0.124622   \n",
       "\n",
       "   feat_86_tfidf  feat_87_tfidf  feat_88_tfidf  feat_89_tfidf  feat_90_tfidf  \\\n",
       "0       0.000000       0.000000            0.0            0.0       0.000000   \n",
       "1       0.000000       0.000000            0.0            0.0       0.000000   \n",
       "2       0.000000       0.000000            0.0            0.0       0.000000   \n",
       "3       0.008244       0.022456            0.0            0.0       0.000000   \n",
       "4       0.000000       0.000000            0.0            0.0       0.145988   \n",
       "\n",
       "   feat_91_tfidf  feat_92_tfidf  feat_93_tfidf   target  \n",
       "0            0.0            0.0            0.0  Class_1  \n",
       "1            0.0            0.0            0.0  Class_1  \n",
       "2            0.0            0.0            0.0  Class_1  \n",
       "3            0.0            0.0            0.0  Class_1  \n",
       "4            0.0            0.0            0.0  Class_1  \n",
       "\n",
       "[5 rows x 95 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#导入数据\n",
    "train_tfidf = pd.read_csv(dpath +\"Otto_FE_train_tfidf.csv\")\n",
    "train_tfidf.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_train_tfidf = train_tfidf['target']   \n",
    "X_train_tfidf = train_tfidf.drop([\"id\", \"target\"], axis=1)\n",
    "\n",
    "train_tfidf_id = train_tfidf['id']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "pca_tfidf = PCA(n_components = 0.85)\n",
    "pca_tfidf.fit(X_train_tfidf)\n",
    "X_train_tfidf_pca = pca_tfidf.transform(X_train_tfidf)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2. 对Otto商品tfidf特征，进行PCA降维，给出各维方差的分布图。（30分） "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEA9JREFUeJzt3H+s3fVdx/Hny3bA3CJsUM1swXahmnUZTnfXLXHqMpQVmesSIZb5oyaYajLMjJuzGMe2OhMwZt0SMbEZaGVqIcwfN1IlBOaPLAvrZbgfHZLdIY5ryShrx8QFurK3f5wv2fFwy/3ee8/t5d7P85E0fL+f7+d7zucTcl+fz/mc7/mkqpAkteG7lrsBkqTTx9CXpIYY+pLUEENfkhpi6EtSQwx9SWqIoS9JDTH0Jakhhr4kNWTtcjdg1HnnnVcbN25c7mZI0opy7733PlZV6+aq97wL/Y0bNzI1NbXczZCkFSXJf/Wp5/KOJDXE0Jekhhj6ktQQQ1+SGmLoS1JDDH1JaoihL0kNMfQlqSGGviQ1pNcvcpNsAz4CrAE+WlXXjVz/CeDDwEXAjqq6bejaTuD3utMPVtX+cTT8VDbuvv1ZZQ9dd9lSvqUkrRhzzvSTrAFuAC4FtgBXJtkyUu0rwK8Afz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YRq82fM9jmYthu4K6q2gzc1Z2vRieBd1XVK4DXA+/o/n+30v+ngDdV1Q8Drwa2JXk9g61Q9nb9P85gq5TV6p3A/UPnLfV93lZd6NNv24hVpar+lcFTU8OGt8bYD7zttDbqNKmqR6rqM93x/zD4419PO/2vqnqiO31B96+ANzHYEgVWcf+TbAAuAz7anYdG+r5QqzH03fph4Puq6hEYBCPwvcvcniXX7e76I8A9NNT/bnnj34FHgTuBLwNf77ZEgdX9N/Bh4D3At7vzc2mn7wuyGkM/s5T5iNIql+TFwMeB36yqbyx3e06nqnq6ql7N4BfvW4FXzFbt9LZq6SV5C/BoVd07XDxL1VXX98Xosw3DStNr64cGfDXJy6rqkSQvYzALXJWSvIBB4P9lVf1NV9xM/59RVV9P8s8Mvts4J8nabsa7Wv8Gfgx4a5KfAc4CvofBzL+Fvi/Yapzp99k2ogXDW2PsBP5+GduyZLo13BuB+6vqQ0OXWun/uiTndMcvBH6Kwfcan2CwJQqs0v5X1TVVtaGqNjL4O7+7qn6BBvq+GKvyx1ndyP9hvrNtxB8sc5OWVJK/Bt7IYHfBrwLvA/4OuBW4APgKcEVVjX7Zu+IleQPwb8Dn+c667u8yWNdvof8XMfiycg2DSdytVbUnycsZPMTwUuA+4Ber6qnla+nSSvJG4N1V9ZbW+j5fqzL0JUmzW43LO5KkUzD0Jakhhr4kNcTQl6SGGPqS1BBDX5IaYuhLUkMMfUlqyP8Bst/13MP2gdUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(range(len(pca_tfidf.explained_variance_ratio_)), pca_tfidf.explained_variance_ratio_)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3. 采用train_test_split，从将数据集中随机抽取10000条记录（原始数据集太大，剩余数据抛弃，此部分SVM作业已经完成）。对这部分数据进行PCA降维，保留85%的能量。（20分） "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(10000, 93)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\Anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_split.py:2179: FutureWarning: From version 0.21, test_size will always complement train_size unless both are specified.\n",
      "  FutureWarning)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "X_train_split, X_test_split, y_train_split, y_test_split = train_test_split(X_train_tfidf,y_train_tfidf,train_size = 10000,random_state=10)\n",
    "\n",
    "train_split_id = train['id']\n",
    "print(X_train_split.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# PCA降维"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "pca_split = PCA(n_components = 0.85)\n",
    "pca_split.fit(X_train_split)\n",
    "\n",
    "X_train_split_pca = pca_split.transform(X_train_split)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEAVJREFUeJzt3X+s3Xddx/Hny5ZtCHGDrhhcN1uyaigBUWolEZUwGZ3DFeMWO1BrMlNNmMEAYmfigIrJZgzFxJnYsOEcxm0Z/mhcdVkY/ghZRu8Yv8pcuMzJLltYR8twmq10vP3jfBdOTk93v/fec3vX83k+kpt+v5/v53vO55Pmvj6f8znnfG6qCklSG75vpRsgSTp5DH1JaoihL0kNMfQlqSGGviQ1xNC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CS3cBMVe0DrgduSjLLYIa/vbv3YJJbgS8Dx4B3VtUzy9QXSdI85l3TP1Ul2dktGzWp5f633Hew/633fz5TG/qSpOO5DYMkNWQqQ3++bSOmTZIbkjyW5EtDZS9NcmeSr3T/vmQl27hckpyb5FNJ7k9yMMm7uvJW+n9Gks8k+XzX/w925Ru6LVG+0m2RctpKt3W5JFmV5L4k/9SdN9P3xZi60O+5bcS0+SsG21wM2wV8sqo2Ap/szqfRMeA9VfVK4PXAO7v/71b6/zTwpqr6MeC1wNYkr2ewFcqerv9HGGyVMq3eBdw/dN5S3xds6kKffttGTJWq+ncGn5oaNrw1xo3A205qo06Sqnq0qj7bHf8Pg1/+c2in/1VVT3anL+h+CngTgy1RYIr7n2QdcDHw0e48NNL3xZrG0Hfrh4EfrKpHYRCMwMtWuD3Lrtvd9ceBe2io/93yxueAx4A7ga8C3+q2RIHp/h34CPA+4Lvd+Rra6fuiTGPoZ0yZH1GackleDHwC+N2q+vZKt+dkqqpnquq1DL7xvgV45bhqJ7dVyy/JW4HHqure4eIxVaeu70vRZxuGU02vrR8a8I0kL6+qR5O8nMEscColeQGDwP+bqvq7rriZ/j+rqr6V5F8ZvLdxVpLV3Yx3Wn8Hfhq4JMkvAGcAP8Bg5t9C3xdtGmf6fbaNaMHw1hg7gH9cwbYsm24N93rg/qr68NClVvq/NslZ3fELgZ9n8L7GpxhsiQJT2v+quqqq1lXVega/53dV1TtooO9LMZVfzupG/o/wvW0j/niFm7Sskvwt8EYGuwt+A3g/8A/ArcB5wNeAy6pq9M3eU16SNwD/AXyR763r/gGDdf0W+v8aBm9WrmIwibu1qnYneQWDDzG8FLgP+NWqenrlWrq8krwReG9VvbW1vi/UVIa+JGm8aVzekSSdgKEvSQ0x9CWpIYa+JDXE0Jekhhj6ktQQQ1+SGmLoS1JD/h8oDfKFz1ARKAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(range(len(pca_split.explained_variance_ratio_)), pca_split.explained_variance_ratio_)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 保存经trian_test_split后的结果\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Int64Index([39091,  6835, 10790, 56394, 37348, 43604,  1550, 22424, 39057,\n",
      "             8621,\n",
      "            ...\n",
      "            17904, 37597, 10201,  9372, 40059, 28017, 50496, 29199, 40061,\n",
      "            17673],\n",
      "           dtype='int64', length=10000)\n",
      "Int64Index([39091,  6835, 10790, 56394, 37348, 43604,  1550, 22424, 39057,\n",
      "             8621,\n",
      "            ...\n",
      "            17904, 37597, 10201,  9372, 40059, 28017, 50496, 29199, 40061,\n",
      "            17673],\n",
      "           dtype='int64', length=10000)\n"
     ]
    }
   ],
   "source": [
    "#保存PCA特征变换结果\n",
    "n_components_split = pca_split.n_components_\n",
    "feat_names_pca_split = []\n",
    "for i in range(n_components_split):\n",
    "    feat_names_pca_split.append(\"pca_split_\" + str(i))\n",
    "\n",
    "y_split = pd.DataFrame(columns =['target'] ,data = y_train_split)\n",
    "x_split =  pd.DataFrame(columns = feat_names_pca_split, data = X_train_split_pca,index=y_split.index)\n",
    "\n",
    "print(y_split.index)\n",
    "print(x_split.index)\n",
    "\n",
    "train_pca_split = pd.concat([ x_split, y_split], axis = 1)\n",
    "train_pca_split.to_csv(dpath +'Otto_FE_train_split_PCA.csv',index=False,header=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pca_split_0</th>\n",
       "      <th>pca_split_1</th>\n",
       "      <th>pca_split_2</th>\n",
       "      <th>pca_split_3</th>\n",
       "      <th>pca_split_4</th>\n",
       "      <th>pca_split_5</th>\n",
       "      <th>pca_split_6</th>\n",
       "      <th>pca_split_7</th>\n",
       "      <th>pca_split_8</th>\n",
       "      <th>pca_split_9</th>\n",
       "      <th>...</th>\n",
       "      <th>pca_split_39</th>\n",
       "      <th>pca_split_40</th>\n",
       "      <th>pca_split_41</th>\n",
       "      <th>pca_split_42</th>\n",
       "      <th>pca_split_43</th>\n",
       "      <th>pca_split_44</th>\n",
       "      <th>pca_split_45</th>\n",
       "      <th>pca_split_46</th>\n",
       "      <th>pca_split_47</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.331222</td>\n",
       "      <td>-0.022211</td>\n",
       "      <td>-0.162469</td>\n",
       "      <td>0.015325</td>\n",
       "      <td>-0.393796</td>\n",
       "      <td>0.365473</td>\n",
       "      <td>-0.193526</td>\n",
       "      <td>-0.066136</td>\n",
       "      <td>-0.174357</td>\n",
       "      <td>0.206604</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.035218</td>\n",
       "      <td>0.062756</td>\n",
       "      <td>-0.040523</td>\n",
       "      <td>-0.043832</td>\n",
       "      <td>0.028288</td>\n",
       "      <td>0.078104</td>\n",
       "      <td>-0.076798</td>\n",
       "      <td>-0.075404</td>\n",
       "      <td>0.052630</td>\n",
       "      <td>Class_6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.685230</td>\n",
       "      <td>0.199180</td>\n",
       "      <td>-0.147661</td>\n",
       "      <td>-0.061614</td>\n",
       "      <td>0.031576</td>\n",
       "      <td>0.004340</td>\n",
       "      <td>-0.038080</td>\n",
       "      <td>-0.068481</td>\n",
       "      <td>-0.138957</td>\n",
       "      <td>-0.071786</td>\n",
       "      <td>...</td>\n",
       "      <td>0.044779</td>\n",
       "      <td>-0.041904</td>\n",
       "      <td>-0.047018</td>\n",
       "      <td>0.019342</td>\n",
       "      <td>0.028996</td>\n",
       "      <td>0.018958</td>\n",
       "      <td>0.001747</td>\n",
       "      <td>-0.018663</td>\n",
       "      <td>0.050354</td>\n",
       "      <td>Class_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.134230</td>\n",
       "      <td>-0.486100</td>\n",
       "      <td>0.111271</td>\n",
       "      <td>-0.466462</td>\n",
       "      <td>0.333791</td>\n",
       "      <td>0.284197</td>\n",
       "      <td>0.006734</td>\n",
       "      <td>0.091678</td>\n",
       "      <td>-0.019579</td>\n",
       "      <td>0.098373</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.031941</td>\n",
       "      <td>0.004416</td>\n",
       "      <td>-0.031056</td>\n",
       "      <td>0.025427</td>\n",
       "      <td>0.097775</td>\n",
       "      <td>0.009618</td>\n",
       "      <td>0.068826</td>\n",
       "      <td>0.006031</td>\n",
       "      <td>-0.050549</td>\n",
       "      <td>Class_2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.028255</td>\n",
       "      <td>-0.032109</td>\n",
       "      <td>-0.015349</td>\n",
       "      <td>0.107275</td>\n",
       "      <td>-0.104765</td>\n",
       "      <td>-0.073262</td>\n",
       "      <td>0.189727</td>\n",
       "      <td>0.200853</td>\n",
       "      <td>0.138135</td>\n",
       "      <td>0.136254</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.107963</td>\n",
       "      <td>-0.164762</td>\n",
       "      <td>0.063887</td>\n",
       "      <td>0.000998</td>\n",
       "      <td>-0.121768</td>\n",
       "      <td>-0.016296</td>\n",
       "      <td>-0.002870</td>\n",
       "      <td>-0.055586</td>\n",
       "      <td>-0.136174</td>\n",
       "      <td>Class_8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.092576</td>\n",
       "      <td>-0.087054</td>\n",
       "      <td>-0.127559</td>\n",
       "      <td>0.044213</td>\n",
       "      <td>-0.226390</td>\n",
       "      <td>-0.020160</td>\n",
       "      <td>0.030440</td>\n",
       "      <td>0.148846</td>\n",
       "      <td>-0.068738</td>\n",
       "      <td>-0.156847</td>\n",
       "      <td>...</td>\n",
       "      <td>0.006563</td>\n",
       "      <td>0.022095</td>\n",
       "      <td>-0.110030</td>\n",
       "      <td>-0.085845</td>\n",
       "      <td>0.108045</td>\n",
       "      <td>0.008977</td>\n",
       "      <td>0.054037</td>\n",
       "      <td>-0.105314</td>\n",
       "      <td>0.067473</td>\n",
       "      <td>Class_6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 49 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   pca_split_0  pca_split_1  pca_split_2  pca_split_3  pca_split_4  \\\n",
       "0    -0.331222    -0.022211    -0.162469     0.015325    -0.393796   \n",
       "1     0.685230     0.199180    -0.147661    -0.061614     0.031576   \n",
       "2    -0.134230    -0.486100     0.111271    -0.466462     0.333791   \n",
       "3    -0.028255    -0.032109    -0.015349     0.107275    -0.104765   \n",
       "4    -0.092576    -0.087054    -0.127559     0.044213    -0.226390   \n",
       "\n",
       "   pca_split_5  pca_split_6  pca_split_7  pca_split_8  pca_split_9  ...  \\\n",
       "0     0.365473    -0.193526    -0.066136    -0.174357     0.206604  ...   \n",
       "1     0.004340    -0.038080    -0.068481    -0.138957    -0.071786  ...   \n",
       "2     0.284197     0.006734     0.091678    -0.019579     0.098373  ...   \n",
       "3    -0.073262     0.189727     0.200853     0.138135     0.136254  ...   \n",
       "4    -0.020160     0.030440     0.148846    -0.068738    -0.156847  ...   \n",
       "\n",
       "   pca_split_39  pca_split_40  pca_split_41  pca_split_42  pca_split_43  \\\n",
       "0     -0.035218      0.062756     -0.040523     -0.043832      0.028288   \n",
       "1      0.044779     -0.041904     -0.047018      0.019342      0.028996   \n",
       "2     -0.031941      0.004416     -0.031056      0.025427      0.097775   \n",
       "3     -0.107963     -0.164762      0.063887      0.000998     -0.121768   \n",
       "4      0.006563      0.022095     -0.110030     -0.085845      0.108045   \n",
       "\n",
       "   pca_split_44  pca_split_45  pca_split_46  pca_split_47   target  \n",
       "0      0.078104     -0.076798     -0.075404      0.052630  Class_6  \n",
       "1      0.018958      0.001747     -0.018663      0.050354  Class_2  \n",
       "2      0.009618      0.068826      0.006031     -0.050549  Class_2  \n",
       "3     -0.016296     -0.002870     -0.055586     -0.136174  Class_8  \n",
       "4      0.008977      0.054037     -0.105314      0.067473  Class_6  \n",
       "\n",
       "[5 rows x 49 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#读取训练数据\n",
    "dpath = './data/'\n",
    "train_RBF = pd.read_csv(dpath +\"Otto_FE_train_split_PCA.csv\")\n",
    "\n",
    "\n",
    "train_RBF.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 准备数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_train_rbf = train_RBF['target']   \n",
    "X_train_rbf = train_RBF.drop([ \"target\"], axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 训练RBF核SVM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "GridSearchCV(cv=6, error_score='raise-deprecating',\n",
       "       estimator=SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,\n",
       "  decision_function_shape='ovr', degree=3, gamma='auto_deprecated',\n",
       "  kernel='rbf', max_iter=-1, probability=False, random_state=None,\n",
       "  shrinking=True, tol=0.001, verbose=False),\n",
       "       fit_params=None, iid='warn', n_jobs=2,\n",
       "       param_grid={'C': [0.01, 0.1, 1, 10, 100, 1000], 'gamma': [0.01, 0.1, 1, 10, 100, 1000]},\n",
       "       pre_dispatch='2*n_jobs', refit=True, return_train_score='warn',\n",
       "       scoring='accuracy', verbose=0)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.svm import SVC\n",
    "from sklearn.metrics import accuracy_score\n",
    "\n",
    "#在训练集上的交叉验证\n",
    "Cs=[0.01,0.1,1,10,100,1000]\n",
    "gamma=[0.01,0.1,1,10,100,1000]\n",
    "param_grid={'C':Cs,'gamma':gamma}\n",
    "\n",
    "svc=SVC(kernel=\"rbf\")\n",
    "SVC_grid = GridSearchCV(svc, param_grid, cv = 6, n_jobs = 2,scoring=\"accuracy\")\n",
    "SVC_grid.fit(X_train_rbf,y_train_rbf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7835\n",
      "{'C': 10, 'gamma': 1}\n",
      "0.01\n",
      "0.1\n",
      "1\n",
      "10\n",
      "100\n",
      "1000\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3Xl8VNX5+PHPmUlmJvueEBJCgARkF8TdWhVxL9TWurbVamuroNalX/cFUUtb61JFW+v6q4p1q6Ci4m5dqiKgbIoQtgTInpBt9vP7Y5ZM9knIz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USAdlsFzgfaXUN/gOfN7WWr9m1IfJHc1CCCGChuOZghBCiC5IUhBCCBEkSUEIIUSQJAUhhBBBkhSEEEIESVIQohNKqcae1+p2+xeVUmP9zxOVUv9QSm31j3L5kVLqUKWUxf98SN5EKqKTJAUh+plSajJg1lqX+F96FN+gdcVa68nABUCmf9C+d4GzIhKoEJ2QpCBEN5TPX5RS65VS65RSZ/lfNymlHvIf+b+mlFqhlDrDv9l5QGCMrXHAocBNWmsvgH8U19f9677iX1+IQUFOW4Xo3k/wjWE/HcgEvlRKfYTvztpCYCqQje8O6sf92xwJLPU/nwys9Q9o1pn1wMGGRC5EH8iZghDdOwpYqrX2aK3LgQ/xNeJHAS9orb1a673A+yHb5AKV4ezcnyycSqmkfo5biD6RpCBE9zobjru71wFaAJv/+QZgulKqu781K2DvQ2xC9DtJCkJ07yPgLP8kJ1nA0cAXwMfAT/3XFnKAY0K22QQUAWittwKrgIX+ET5RShUrpeb5n2cAlVpr10B9ISG6I0lBiO79B/gG+Bp4D/g/f7noJXzzN6wH/oFv9q96/zav0zZJ/BrfBEhblFLrgH/SOs/DscAKY7+CEOGTUVKF6COlVKLWutF/tP8FcKTWeq9/zPv3/ctdXWAO7ONl4PphMoe2iALS+0iIvnvNP/mJBVjkP4NAa92ilLoV3/zQO7va2D8R0CuSEMRgImcKQgghguSaghBCiCBJCkIIIYIkKQghhAiSpCCEECJIkoIQQoggSQpCCCGC/j8oKAVXMmciuAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(SVC_grid.best_score_)\n",
    "print(SVC_grid.best_params_)\n",
    "test_means=SVC_grid.cv_results_['mean_test_score']\n",
    "\n",
    "n_Cs=len(Cs)\n",
    "n_gamma=len(gamma)\n",
    "test_score=np.array(test_means).reshape(n_Cs,n_gamma)\n",
    "x_axis=np.log10(Cs)\n",
    "for j,value in enumerate(gamma):\n",
    "    val=gamma[j]\n",
    "    plt.plot(x_axis,test_score[:,j],label=val)\n",
    "    print(gamma[j])\n",
    "plt.legend()\n",
    "plt.xlabel( 'log(C)' )                                                                                                      \n",
    "plt.ylabel( 'accuracy' )\n",
    "#plt.savefig('SVM_Otto.png' )\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4. 对3中得到的数据（对降维后的数据），训练RBF核SVM，并对超参数（C和gamma）进行超参数调优。结果和用原始数据的情况比较（SVM部分作业结果）。（30分） \n",
    "答：最优参数C=10，gamma=1.\n",
    "RBFSVM当时正确率为0.8074，RBFSVM的正确率要略高些."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
